#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int mkfifo(const char *pathname, mode_t mode);
int main()
{
    umask(0);
    int result = mkfifo("mypipe", 0664);
    if (result != 0)
    {
        perror("mkfifo");
        exit(1);
    }
    int fd = open("mypipe", O_WRONLY);
    if (fd == -1)
    {
        perror("open");
        exit(1);
    }
    while (1)
    {
        char buffer[1024];
        printf("Enter messages to send: ");
        scanf("%s", buffer);
        int w = write(fd, buffer, strlen(buffer));
        if (w != strlen(buffer))
        {
            perror("write");
            close(fd);
            exit(1);
        }
        if (strcmp(buffer, "exit") == 0)
        {   
            break;
        }   
    }

    close(fd);

    return 0;
}